home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Web Server / PHP.EXE / pear / PHPDoc / renderer / html / PhpdocHTMLModuleRenderer.php < prev    next >
Encoding:
PHP Script  |  2001-02-18  |  3.4 KB  |  95 lines

  1. <?php
  2. /**
  3. * Renders modules.
  4. *
  5. * @version    $Id: PhpdocHTMLModuleRenderer.php,v 1.5 2001/02/18 16:29:21 uw Exp $
  6. */
  7. class PhpdocHTMLModuleRenderer extends PhpdocHTMLDocumentRenderer {
  8.  
  9.     /**
  10.     * Sets the xml and template root directory.
  11.     * 
  12.     * @param    string  XML file path
  13.     * @param    string  Template file path
  14.     * @param    string  Name of the current application
  15.     * @param    string  Filename extension
  16.     * @see      setPath(), setTemplateRoot()
  17.     */
  18.     function PhpdocHTMLModuleRenderer($path, $templateRoot, $application, $extension = ".html") {
  19.  
  20.         $this->setPath($path);
  21.         $this->setTemplateRoot($templateRoot);
  22.         $this->application = $application;
  23.         $this->file_extension = $extension;
  24.  
  25.         $this->accessor = new PhpdocModuleAccessor;
  26.         $this->tpl = new IntegratedTemplate($this->templateRoot);
  27.         $this->fileHandler = new PhpdocFileHandler;
  28.  
  29.     } // end constructor
  30.  
  31.     /**
  32.     * Renders a module
  33.     *
  34.     * @param    string  XML source file
  35.     * @param    string  Name of the HTML target file.
  36.     * @access   public
  37.     */    
  38.     function renderModule($xmlfile, $htmlfile = "") {
  39.  
  40.         $this->tpl->loadTemplatefile("module.html");    
  41.         if ("" == $htmlfile)
  42.             $htmlfile = substr($xmlfile, 7, -4) . $this->file_extension;
  43.  
  44.         $this->accessor->loadXMLFile($this->path . $xmlfile);
  45.         $module = $this->accessor->getModuledata();        
  46.  
  47.         $this->renderFunctions();
  48.         $this->renderUses();
  49.         $this->renderConstants();
  50.  
  51.         $tplvars = array();
  52.         $tplvars["MODULE_FILE"]     = $module["file"]["value"];
  53.         $tplvars["MODULE_NAME"]     = $module["name"];
  54.         $tplvars["MODULE_GROUP"]    = $module["group"];
  55.         $tplvars["MODULE_ACCESS"]   = $module["access"];
  56.         $tplvars["MODULE_PACKAGE"]  = $module["package"];
  57.         $tplvars["MODULE_UNDOC"]    = ("true" == $module["undoc"]) ? $this->undocumented : "";
  58.  
  59.         if (isset($module["doc"]["link"]))
  60.             $this->renderLinks($module["doc"]["link"], "class_");
  61.  
  62.         if (isset($module["doc"]["author"]))
  63.             $this->renderAuthors($module["doc"]["author"], "class_");
  64.  
  65.         if (isset($module["doc"]["see"]))
  66.             $this->renderSee($module["doc"]["see"], "class_");
  67.  
  68.         $fields = array(     "version", "deprecated", "copyright", "since", "magic");
  69.         reset($fields);
  70.         while (list($k, $field) = each($fields)) 
  71.  
  72.             if (isset($module["doc"][$field])) {
  73.                 $this->tpl->setCurrentBlock("module_" . strtolower($field));
  74.                 $this->tpl->setVariable(strtoupper($field), $module["doc"][$field]["value"]);
  75.                 $this->tpl->parseCurrentBlock();
  76.             }
  77.  
  78.         $fields = array( "description", "shortdescription" );
  79.         reset($fields);
  80.         while (list($k, $field) = each($fields)) 
  81.  
  82.             if (isset($module["doc"][$field]))
  83.                 $tplvars["MODULE_" . strtoupper($field)] = $this->encode($module["doc"][$field]["value"]);
  84.  
  85.         $this->tpl->setCurrentBlock("__global__");
  86.         $this->tpl->setVariable($tplvars);
  87.         $this->tpl->setVariable("APPNAME", $this->application);
  88.  
  89.         $this->fileHandler->createFile($this->path . $htmlfile, $this->tpl->get() );
  90.         $this->tpl->free();    
  91.  
  92.     } // end func renderModule
  93.  
  94. } // end class PhpdocHTMLModuleRenderer
  95. ?>